<?php
	include "class/hotels.php";
	include "class/breadcrumb.php";
	// Represent Variable
	$destination = $_GET['des'];
	$hotel = $_GET['hot'];
	
	// Get Hotels
	if(isset($destination) && !empty($destination)){
		$hotels = Hotels::getHotelDestination($destination);
	} else if(isset($hotel) && !empty($hotel)){
		$hotels = Hotels::getHotelDetail($hotel);
	}
	
	// Global Search
	if(!empty($_POST['global_search'])){
		if(!empty($_POST['destination_slug'])){
			header('Location: '.$_POST['destination_slug']."/");
		} else if(!empty($_POST['hotel_slug'])){
			header('Location: '.$_POST['hotel_slug'].".html");
		} else {
			include "class/search.php";
			$result = Search::globalSearch($_POST['global_search']);
			
			if($result['destination'] == 1){
				$hotels = $result['value'];
				$destination = 1;
			} else if($result['hotel'] == 1){
				$hotels = $result['value'];
				$hotel = 1;
			}
		}
	}	
	
	// Get Page
	if(isset($destination) && !empty($destination)){
		$page = "pages/search.php";
	} else if(isset($hotel) && !empty($hotel)){
		$page = "pages/single.php";
	} else {
		$page = "pages/home.php";
	}
?>